#!/bin/bash

path=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
config=$path/config
bin=$path/bin
yunzai=`cat $config/yunzai.txt`
devenv=$path/devenv
env=$devenv/system_env

#检测环境文件是否存在
if [ -f $devenv/system_bin/export.sh ];then
	source $devenv/system_bin/export.sh
fi
if [ -f $devenv/system_bin/node18.sh ];then
	source $devenv/system_bin/node18.sh
fi
if [ -f $devenv/system_bin/java8.sh ];then
	source $devenv/system_bin/java8.sh
fi
if [ -f $devenv/system_bin/python3.10.sh ];then
	source $devenv/system_bin/python3.10.sh
fi

echo "检测是否安装了devenv"
if [[ ! -f $devenv/system_bin/export.sh ]];then
	echo "未安装或者未刷新窗口环境变量"
	
	source $devenv/setup.sh 3 "yzenv"
	source /etc/bash.bashrc
	
	#source $devenv/system_bin/export.sh
fi

echo "检测是否安装了nodejs"

if [[ ! -d $env/node18 && `which node | grep "node18"` == "" ]];then
	#静默安装参考参数顺序
	#tool=$1     工具
	#version=$2  版本
	#method=$3   1.编译安装 2.下载现成的
	#export=$4   1.shell调用 2.环境变量
	#clear=$5    y.清理重新配置 
	source $devenv/install.sh node 18 2 1 y
	source $devenv/system_bin/node18.sh
fi

echo "检测是否安装了java(jdk)"
if [[ ! -d $env/java8 && `which java | grep "java8"` == "" ]];then
	source $devenv/install.sh java 8 2 1 y
	source $devenv/system_bin/java8.sh
fi

echo "检测是否安装了python"
if [[ ! -d $env/python3.10 && `which python | grep "python3.10"` == "" ]];then
	source $devenv/install.sh python 3.10 1 1 y
	source $devenv/system_bin/python3.10.sh
fi

cd $path



